package com.cy;

import com.cy.lister.MyLister;
import com.cy.service.PortInit;
import com.cy.util.SerialPortUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import javax.annotation.PreDestroy;

@SpringBootApplication
public class SerialPortTestApplication
{

    public static void main(String[] args)
    {
        SpringApplication.run(SerialPortTestApplication.class, args);
    }

    @PreDestroy
    public void destroy()
    {
        //关闭应用前 关闭端口
        SerialPortUtil serialPortUtil = SerialPortUtil.getSerialPortUtil();
        serialPortUtil.removeListener(PortInit.serialPort, new MyLister());
        serialPortUtil.closePort(PortInit.serialPort);
    }

}
